﻿using Db4objects.Db4o;

namespace DataAccess
{

    /// <summary>
    /// Update-and-store action class.
    /// </summary>
    class UpdateStoreAction : IUpdateAction
    {

        /// <summary>
        /// The object to be stored anew, or to be updated, if it has already
        /// been stored before.
        /// </summary>
        private object objectToUpdate;


        /// <summary>
        /// UpdateStoreAction constructor.
        /// </summary>
        /// <param name="objectToUpdate">The object to be stored anew, or to be updated, if it has already
        /// been stored before</param>
        public UpdateStoreAction(object objectToUpdate)
        {
            this.objectToUpdate = objectToUpdate;
        }
        
        
        /// <summary>
        /// Performs the update (or new store) action against the database.
        /// </summary>
        /// <param name="db">The database handle</param>
        public void PerformUpdate(IObjectContainer db)
        {
            db.Store(objectToUpdate);
        }

    }

}
